#include "SockInfo.hpp"

SockInfo::SockInfo(int		port)
  : Port(port)
{
}

void SockInfo::InitTcpSiSr()
{
  Sin.sin_family = AF_INET;
  Sin.sin_port = htons(Port);
  Sin.sin_addr.s_addr = INADDR_ANY;
}

void SockInfo::InitTcpSiCl(std::string machine)
{
  Sin.sin_family = AF_INET;
  Sin.sin_port = htons(Port);
  Sin.sin_addr.s_addr = inet_addr(machine.c_str());
}

void SockInfo::InitUdpSiSr()
{
  Sin.sin_family = AF_INET;
  Sin.sin_addr.s_addr = htonl(INADDR_ANY);
  Sin.sin_port = htons(Port);
}

void SockInfo::InitUdpSiClSource()
{
  Sin.sin_family  = AF_INET;
  Sin.sin_addr.s_addr = htonl(INADDR_ANY);
  Sin.sin_port = htons(0);
}

void SockInfo::InitUdpSiClTarget()
{
  Sin.sin_family = AF_INET;
  Sin.sin_port = htons(Port);
  inet_aton("127.0.0.1", &Sin.sin_addr);
}

SockInfo::~SockInfo(void)
{
}

struct sockaddr_in &SockInfo::GetSin(void)
{
  return Sin;
}
